﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.Data;

using System.Windows.Controls;

namespace HA.ModFlow.Application
{
   public class Scatter2dViewModel:MDTVIViewModel
    {
       public Scatter2dViewModel(MDTVIViewModel parent, Scatter2D data)
           : base(parent, false)
       {
           this._scatterData = data;

           this._contextMenu = new System.Windows.Controls.ContextMenu();
           MenuItem mi = new MenuItem();
           mi.Header = "缩放到...";
           mi.Command = GISCommands.ExtentToCurrent;

           mi.CommandParameter = this._scatterData.Key.ToString();

           this._contextMenu.Items.Add(mi);

           this._contextMenu.Items.Add(new Separator());



           mi = new MenuItem();
           mi.Header = "删除";
           mi.Command = Data2Commands.RemoveSatter2D;
           mi.CommandParameter = data;

           this._contextMenu.Items.Add(mi);

           //mi = new MenuItem();
           //mi.Header = "重命名";
           //this._contextMenu.Items.Add(mi);

           Separator sepa = new Separator();
           this._contextMenu.Items.Add(sepa);

           mi = new MenuItem();
           mi.Header = "插值到";
        
           //子项
           MenuItem menu;

           //menu= new MenuItem();
           //menu.Header = "Active TIN";
           //mi.Items.Add(menu);

           // menu = new MenuItem();
           //menu.Header = "2D Mesh";
           //mi.Items.Add(menu);

           //menu = new MenuItem();
           //menu.Header = "2D Grid";
           //mi.Items.Add(menu);

           //menu = new MenuItem();
           //menu.Header = "3D Mesh";
           //mi.Items.Add(menu);

           menu = new MenuItem();
           menu.Header = "三维网格";
           menu.Command = Data2Commands.Scatter2DToGrid3d;
           menu.CommandParameter = this._scatterData;
           mi.Items.Add(menu);


           menu = new MenuItem();
           menu.Header = "MODFLOW图层";
           menu.Command = Data2Commands.Scatter2DToModflowLayer;
           menu.CommandParameter = this._scatterData;
           mi.Items.Add(menu);


           //子项结束
           this._contextMenu.Items.Add(mi);



           //mi = new MenuItem();
           //mi.Header = "Convert To";

           ////子项
           //menu = new MenuItem();
           //menu.Header = "TIN";
           //mi.Items.Add(menu);

           //menu = new MenuItem();
           //menu.Header = "2D Mesh Nodes";
           //mi.Items.Add(menu);

           //menu = new MenuItem();
           //menu.Header = "Observaiton points";
           //mi.Items.Add(menu);
           ////子项结束
           //this._contextMenu.Items.Add(mi);

        


           //mi = new MenuItem();
           //mi.Header = "边框转为Grid2D...";
           //this._contextMenu.Items.Add(mi);



           mi = new MenuItem();
           mi.Header = "边框转为Grid3D...";
           mi.Command = Data2Commands.ScatterBoundToGrid3D;
           mi.CommandParameter = this._scatterData;
           this._contextMenu.Items.Add(mi);


           mi = new MenuItem();
           mi.Header = "编辑离散点";
           mi.Command = Data2Commands.EditScatterPoint;
           mi.CommandParameter = this._scatterData;
           this._contextMenu.Items.Add(mi);



           this._imageSource = VMImageSource.Scatter2d;

       }


       Scatter2D _scatterData;

       public Scatter2D ScatterData
       {
           get { return _scatterData; }
          
       }


       public override string Desc
       {
           get
           {
               return this._scatterData.Name;
           }
       }

       protected override void OnCheckedChanged()
       {
           GisModule.DefaultModule.SetLayerVisible(this._scatterData.Key.ToString(), this.IsChecked);
       }

       protected override void OnSelectedChanged()
       {
           if (this.IsSelected)
           {
               if (this._scatterData != null)
                   GisModule.DefaultModule.GisManager.InteractiveSystem.CurrentLayer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(this._scatterData.Key.ToString());


               UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.SCATTER2D;
               //用于提供给插值用，其中包括克里金插值
               ProjectService.DefaultService.Project.InterpolationOption2D.Scatter2d = this._scatterData;

           }
           else
           {
               //用于提供给插值用，其中包括克里金插值
               ProjectService.DefaultService.Project.InterpolationOption2D.Scatter2d = null;
           }
       }
    }
}
